package cn.meike.net.protocol
{
	import flash.utils.ByteArray;

	public class LoginServer_Request
	{
		public var m_uiUin:uint;
		public var m_uiSeq:uint;
		
		public function LoginServer_Request()
		{
			m_uiUin = 0;
		}
		
		public function encode(buf:ByteArray, cutVersion:uint = 0):int {
			// adjust cutversion
			if (cutVersion == 0 || cutVersion > CURRVERSION) {
				cutVersion = CURRVERSION;
			}
			
			const savedBufBeginPos : uint = buf.position;
			
			var ret : int = ErrorMap.NO_ERROR;
			
			if (VERSION_m_uiUin <= cutVersion) {
				buf.writeInt(m_uiUin);
			}
			
			if (VERSION_m_uiSeq <= cutVersion) {
				buf.writeInt(m_uiSeq);
			}
			
			return ret;
		}
		
		public function decode(buf:ByteArray, cutVersion:uint = 0):int 
		{
			if (cutVersion == 0 || cutVersion > CURRVERSION) {
				cutVersion = CURRVERSION;
			}
			
			const savedBufBeginPos : uint = buf.position;
			
			var ret : int = ErrorMap.NO_ERROR;
			
			if (VERSION_m_uiUin <= cutVersion) {
				if (buf.bytesAvailable < 1) {
					return ErrorMap.ERR_PARTIAL_MSG;
				}
				m_uiUin = buf.readInt();
			}
			
			if (VERSION_m_uiSeq <= cutVersion) {
				if (buf.bytesAvailable < 1) {
					return ErrorMap.ERR_PARTIAL_MSG;
				}
				m_uiSeq = buf.readInt();
			}
			
			
			return ret;
			
		}
		
		static public const BASEVERSION : uint = 1;
		static public const CURRVERSION : uint = 27;
		static public const VERSION_m_uiUin : uint = 1;
		static public const VERSION_m_uiSeq : uint = 1;
		

	}
}